/**
 * Applikationsutveckling i Java, 5DV135
 * HT12
 * Project
 * 
 * File: MapTest.java
 * Description: A class for representing a map.
 * Date: 13 december 2012
 * 
 * cs-user: dv11rlm
 * @author Robert Lundström
 */
package nullInvader.Engine;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import java.awt.Point;
import java.util.ArrayList;
import java.util.concurrent.ConcurrentHashMap;

import nullInvader.Engine.Goal;
import nullInvader.Engine.Road;
import nullInvader.Engine.Tower;
import nullInvader.Engine.UnitInfo;
import nullInvader.Engine.WatchTower;
import nullInvader.Engine.Zone;

import org.junit.BeforeClass;
import org.junit.Test;

public class MapTest {

    private static ConcurrentHashMap<Point, Zone> hashMap;
    private static ArrayList<UnitInfo> priceList;
    private static ArrayList<Tower> towerList;
    private static ArrayList<Zone> reachablesList;
    private static WatchTower testTower;
    private static ArrayList<Point> goalList;
    private static Map m;

    @BeforeClass
    static public void setUp() {
	hashMap = new ConcurrentHashMap<Point, Zone>();
	hashMap.put(new Point(1, 1), new Zone(new Road(true)));
	hashMap.put(new Point(1, 2), new Zone(new Goal(true)));

	priceList = new ArrayList<UnitInfo>();
	towerList = new ArrayList<Tower>();
	reachablesList = new ArrayList<Zone>();
	for (Point p : hashMap.keySet()) {
	    reachablesList.add(hashMap.get(p));
	}
	testTower = new WatchTower(true, new Point(1, 3));
	testTower.setReachableZones(reachablesList);
	towerList.add(testTower);
	goalList = new ArrayList<Point>();
	goalList.add(new Point(1, 2));
	m = new Map(hashMap, "testMap", 100, 40, new Point(1, 1),
		goalList,
		priceList, towerList);
    }

    @Test
    public void checkGoalAndStrart() {
	assertFalse(m.getGoal().get(0).equals(m.startPosition));
    }

    @Test
    public void checkGoalPositions() {
	for (int i = 0; i < m.getGoal().size(); i++) {
	    assertTrue(m.getGoal().get(i).equals(m.getGoal().get(i)));
	}
    }

    @Test
    public void getNameTest() {
	assertEquals(m.mapName, m.getName());
    }

    @Test
    public void cashTest() {
	assertEquals(m.startCash, m.getStartCash());
    }

    @Test
    public void endScore() {
	assertEquals(m.goalScore, m.getGoalScore());
    }

}
